package org.jeecg.modules.basic.group.service.impl;

import org.jeecg.modules.basic.entry.util.HttpRequestToPrivate;
import org.jeecg.modules.basic.entry.util.HttpRequestToPublic;
import org.jeecg.modules.basic.entry.util.SenseTimeEnumToPrivate;
import org.jeecg.modules.basic.entry.util.SenseTimeEnumToPublic;
import org.jeecg.modules.basic.group.entity.LwgyInoutGroup;
import org.jeecg.modules.basic.group.mapper.LwgyInoutGroupMapper;
import org.jeecg.modules.basic.group.service.ILwgyInoutGroupService;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import static org.jeecg.modules.basic.entry.util.StringUtil.getMD5;

/**
 * @Description: 人员组列表
 * @Author: jeecg-boot
 * @Date:   2021-03-25
 * @Version: V1.0
 */
@Service
public class LwgyInoutGroupServiceImpl extends ServiceImpl<LwgyInoutGroupMapper, LwgyInoutGroup> implements ILwgyInoutGroupService {
    @Override
    public String queryGroupToPublic(String type){
        if(type == null || type.equals("0")){
            type="1";
        }
        String url = SenseTimeEnumToPublic.HOST.getMsg() + SenseTimeEnumToPublic.GROUP_URL.getMsg();//https://link.bi.sensetime.com/api/v1/group
        String timestamp = String.valueOf(System.currentTimeMillis());
        //添加表单文本参数
        String params =
                "&type="+Integer.parseInt(type)+"&size=1000&app_key="+ SenseTimeEnumToPublic.APP_KEY.getMsg()+"" +
                        "&timestamp="+timestamp+"" +
                        "&sign="+ getMD5(timestamp + "#" + SenseTimeEnumToPublic.APP_SECRET.getMsg());
        String result = HttpRequestToPublic.sendGet(url, params);
        return result;
    }

    @Override
    public String queryGroupToPrivate(String type){
        if(type == null || type.equals("0")){
            type="1";
        }
        String url = SenseTimeEnumToPrivate.HOST.getMsg() + SenseTimeEnumToPrivate.GROUP_URL.getMsg();//https://link.bi.sensetime.com/api/v1/group
        String timestamp = String.valueOf(System.currentTimeMillis());
        //添加表单文本参数
        String params ="&type="+Integer.parseInt(type)+"&size=1000";
        String result = HttpRequestToPrivate.sendGet(url, params);
        return result;
    }

}
